#include <stdio.h>
#include <string.h>
#include "main.h"
#include "fun.h"

const char *image_path = "/home/orangepi/Install_AnomalyCLIP/Datasets/mvtec/bottle/test/broken_large/000.png";


#ifndef QUANTIZATION //float
const char *model_path = "/home/orangepi/Install_AnomalyCLIP/AnomalyCLIP_fp16.rknn";
// const char *model_path = "/home/orangepi/Install_AnomalyCLIP/test_fp16.rknn";
#endif

#ifdef QUANTIZATION //int
// const char *model_path = "/home/orangepi/Install_AnomalyCLIP/test_int8.rknn";
// const char *model_path = "/home/orangepi/Install_AnomalyCLIP/AnomalyCLIP_int8.rknn";
#endif





int main(void)
{
    int ret;
    //choose the input image && resize to 518*518
    image_buffer_t image_info;
    ret = load_and_transform_image(&image_info, image_path); //read + preprocess(resize)
    if(ret != 0){printf("main.cc: image init failure\n"); return -1;}


    //set up AnomalyCLIP model
    model_context model_ctx;
    ret = init_model(&model_ctx, model_path);
    if(ret != 0){printf("main.cc: model init failure\n"); return -1;}
    
    /* -------------------------- inference -------------------------- */
    ret = inference(&model_ctx, &image_info);
    if(ret!=0 ){printf("main.cc: inference failure\n"); return -1;}

    //free memory
    free_model(&model_ctx);
    free_image(&image_info);
    return 0;
}
